#include <iostream>
using namespace std;
#include <sys/types.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/wait.h>
int  main()
{
    /*孤儿进程*/
    /*创建进程*/
    pid_t pid = fork();
    if(pid < 0)
    {
        perror("fork error");
        exit(-1);
    }
    else if(pid == 0)
    {
        /*子进程*/
        cout<<"I am child process and..."<<endl;
        // int cnt = 100;
        // while(cnt--)
        // {
        //     cout<<"I am child process."<<endl;
        //     sleep(1);
        // }

    }
    else
    {
        /*父进程*/
        cout<<"I am parent process and..."<<endl;
        int cnt = 100;
        while(cnt--)
        {
            cout<<"I am parent process."<<endl;
            sleep(1);
        }
    }
    return 0;

}